home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility3 / jfklib.zip / MDIDEMO.CPP < prev    next >
Text File  |  1991-05-11  |  2KB  |  119 lines

  1. /*
  2.     MDIDEMO.CPP - (C) 1991 by Joachim Kainz 'On a mission from Bhudda'
  3. */
  4.     #include "mdidemo.hpp"
  5.     #include <string.h>
  6.  
  7.     WORD DEMOCHILD::wCount = 0;
  8.  
  9.     int PASCAL WinMain (
  10.                 HANDLE    hInst,
  11.                 HANDLE    hPrevInstance,
  12.                 LPSTR    lpCmdLine,
  13.                 int        nCmdShow
  14.                )
  15.     {
  16.         SetInstance (hInst);
  17.  
  18.         MDIDEMO mdi (nCmdShow);
  19.  
  20.         if (!IsWindow (mdi))
  21.             return FALSE;
  22.  
  23.         new DEMOCHILD ();
  24.  
  25.         return MsgLoop (mdi);
  26.     }
  27.  
  28.     DEMOCHILD::DEMOCHILD () :
  29.         MDICHILD (MAKEINTRESOURCE (ID_FONT+(wCount++)%7))
  30.     {
  31.         LOGFONT lf;
  32.  
  33.         memset (&lf, 0, sizeof lf);
  34.  
  35.         GetWindowText (
  36.             GetWindowHandle (),
  37.             (LPSTR) lf.lfFaceName,
  38.             sizeof lf.lfFaceName
  39.         );
  40.         lf.lfHeight  = 38;
  41.         lf.lfWidth   = 50;
  42.         lf.lfQuality = PROOF_QUALITY;
  43.  
  44.         hFont  = CreateFontIndirect (&lf);
  45.         pTitle = new char [20];
  46.  
  47.         LoadString (GetInstance (), ID_HI_FOLKS, pTitle, 20);
  48.  
  49.         InvalidateRect (GetWindowHandle (), NULL, TRUE);
  50.     }
  51.  
  52.     METHOD DEMOCHILD::WMPaint()
  53.     {
  54.         PAINTSTRUCT ps;
  55.         RECT        rt;
  56.  
  57.         BeginPaint      (GetWindowHandle (), &ps);
  58.  
  59.         SetMapMode       (ps.hdc,         MM_ANISOTROPIC);
  60.         GetClientRect  (GetWindowHandle (),     &rt);
  61.         SetViewportExt (ps.hdc, rt.right, rt.bottom);
  62.         SetWindowOrg   (ps.hdc, 0,    0                  );
  63.  
  64.         rt.right  = 450;
  65.         rt.bottom = 40;
  66.  
  67.         SetWindowExt (ps.hdc, rt.right, rt.bottom);
  68.  
  69.         HFONT hOldFont = SelectObject (ps.hdc, hFont);
  70.  
  71.         DrawText (
  72.             ps.hdc,
  73.             pTitle,
  74.             -1,
  75.             &rt,
  76.             DT_CENTER | DT_VCENTER | DT_SINGLELINE
  77.         );
  78.  
  79.         SelectObject (ps.hdc, hOldFont);
  80.  
  81.         EndPaint  (GetWindowHandle (), &ps);
  82.  
  83.         return 0l;
  84.     }
  85.  
  86.     METHOD DEMOCHILD::WMDestroy ()
  87.     {
  88.         delete pTitle;
  89.  
  90.         DeleteObject (hFont);
  91.  
  92.         return MDICHILD::WMDestroy ();
  93.     }
  94.  
  95.     MDIDEMO::MDIDEMO (int nShow) : MDI (SW_HIDE)
  96.     {
  97.         HMENU hMenu = GetMenu (GetWindowHandle ());
  98.  
  99.         MDISetMenu (
  100.             hMenu,
  101.             GetSubMenu (hMenu, 1)
  102.         );
  103.  
  104.         ShowWindow (self, nShow);
  105.     }
  106.  
  107.     METHOD MDIDEMO::WMCommand (WORD wID, WORD wMsg, HWND hCtl)
  108.     {
  109.         switch (wID) {
  110.  
  111.           case ID_FILE_OPEN:
  112.             new DEMOCHILD ();
  113.             return 0l;
  114.  
  115.         }
  116.  
  117.         return MDI::WMCommand (wID, wMsg, hCtl);
  118.     }
  119.